﻿
using System.Windows.Forms;

namespace CutShuFa.AutoAction
{
    public class IntParameterControl : TempUserControl, IParameterControl
    {
        private NumericUpDown numericUpDown;
        private Parameter _parameter;

        public IntParameterControl() : base()
        {
            numericUpDown = new NumericUpDown();
            // 设置数字输入框的属性，只允许输入整数
            numericUpDown.Minimum = 0;
            numericUpDown.Maximum = int.MaxValue;
            numericUpDown.Value = 0;

            panel.Controls.Add(numericUpDown);
        }

        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
        }

        public Parameter GetParameter()
        {
            _parameter.Value = numericUpDown.Value.ToString();
            return _parameter;
        }

        public void Init(Parameter parameter)
        {
            _parameter = parameter;
            if (string.IsNullOrEmpty(parameter.Value))
            {
                return;
            }
            numericUpDown.Value = Convert.ToInt32(parameter.Value);
            lb_title.Text = parameter.Name;
        }
    }
}